package org.hagopa.games.moneypool.utils;


import java.io.UnsupportedEncodingException;
import java.sql.Date;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;

public class LogRecord {
        private int serverId = 0;
        private long gameId;
        private long clientId = 0;
        private LogActionTypeEnum action = null; //action_type explains which action type was performed: Login, Disconnect, Join, Start
        private Date logTime = null;

	private String msg=null;
	private int msg_type; //FAILED - 0, PENDING - 1, SUCCES - 2
	

        public LogRecord(int servId, long gid, long cid, int msg_type, String actionmsg) 
        {
            this.serverId = servId;
            this.gameId = gid;
            this.clientId = cid;
           // this.action = action_type;
            this.msg_type = msg_type;
            String msgtype = "";
            switch(msg_type){
                case 0:
                    msgtype = "[TRACE]";
                    break;
                case 1:
                    msgtype = "[WARN]";
                    break;
                case 2:
                    msgtype = "[ERROR]";
                    break;
                case 3:
                    msgtype = "[UNDEFINED]";
                    break;
                default:
                    msgtype = "[DEBUG]";
            }
        try {
            this.msg = msgtype + java.net.URLEncoder.encode(actionmsg, "UTF-8");
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(LogRecord.class.getName()).log(Level.SEVERE, null, ex);
        }
        
            this.logTime = new java.sql.Date(System.currentTimeMillis());
        }
        
	public long getGameId()
        {
		return this.gameId;
	}
        public int getservId()
        {
            return serverId;
        }
	public void setGameId(int gameId) {
		this.gameId = gameId;
	}

        public long getClientId()
        {
            return this.clientId;
        }
        
        public LogActionTypeEnum getActionType()
        {
            return this.action;
        }
        public Date getLogTime()
        {
            return this.logTime;
        }
	public String getMsg() {
		return msg;
	}
	
	public int getStatus() {
		return msg_type;
	}
	
}
